install.packages("tidyverse")1 Get started with readr and the tidyverse
Before you start, make sure to install the tidyverse packages by calling
This will install readr along with other tidyverse packages.
Remember to put library(tidyverse) (or library(readr)) on top of your script to access the readr functions.
1.1 Write a tibble to disk
Let’s use the animals tibble from the previous task and write it into the data folder in our project.
Before writing the tibble
- Create a
datasub-folder in your RStudio project (if you don’t have one yet)- Hint: You can do that from within RStudio by using the
New Folderbutton in the Files pane
- Hint: You can do that from within RStudio by using the
Now write the animals tibble into that /data sub-directory as animals.csv using a comma separator.
Check if the file was written into the correct folder.
2 Read data into R
Now, try to read the data set back into R using the appropriate read_* function.
Make sure that you save the table you read in in a new variable to have it available for later use.
Don’t type the input path of the table to read. Instead, make the “” to start writing the path and then us the tab key on your keyboard to auto-complete.
3 Extra
Navigate to your
data/folder using the Files pane of RStudio. Click on the.csvfile that you just saved there. What can you do? Try the Import Dataset button and see what you can do there.Try reading some
xlsxorcsvtables that you have on your machine into R- First copy the table into the
data/folder in your project, then use the appropiate function to read in the data
- First copy the table into the